package com.practice.aaDatatype001;

final class CompareUtil {

    public static boolean compare(double var1, double var2) {
        return var1 == var2;
    }

    public static boolean compare(float var1, double var2) {
        return var1 == var2;
    }
}


class Test {

    static void f(String var) {
    }

    static void f(Integer var) {
    }

    static void g(double var) {
    }

    static void g(Integer i) {
    }

    // 正确编译，泛型中的类型擦除
    <String, T, Alibaba> String get(String string, T t) {
        return string;
    }

    public static void main(String[] args) {
        float a = 0.125f;
        double b = 0.125d;
        System.out.println((a - b) == 0.0);


        System.out.println("\n");
        double c = 0.8;
        double d = 0.7;
        double e = 0.6;
        double cd = c - d;
        double de = d - e;
        System.out.println(c);
        System.out.println(d);
        System.out.println(e);
        System.out.println(cd);
        System.out.println(de);
        System.out.println(cd == de);

        System.out.println("\n");
        System.out.println(1.0 / 0);//Infinity(无穷大)
        //System.out.println(1/0);//Exception in thread "main" java.lang.ArithmeticException: / by zero
        System.out.println(1 / 0.0);//Infinity(无穷大)
        System.out.println(0.0 / 0);//NaN
        System.out.println(0 / 0.0);//NaN
        System.out.println(-1.0 / 0);//-Infinity(无穷小)
        System.out.println(0.0 / 0.0);//NaN(Double 中的定义 public static final double NaN = 0.0d / 0.0;)
        System.out.println(0.0d / 0.0);
        System.out.println(1.0 / 0.0);//Infinity(Double 中的定义 public static final double NEGATIVE_INFINITY = -1.0 / 0.0;)

        System.out.println("\n");
        //f(null); //编译出错
        g(1);//调用基本数据类型的重载方法

        System.out.println("\n");
//        String n = null;//Exception in thread "main" java.lang.NullPointerException
//        switch (n) {
//            case "null" :
//                System.out.println("hello");
//                break;
//            default:
//                System.out.println("world");
//                break;
//        }

    }
}